Skip to content

fix(detector-aws): extract full container ID from ECS Fargate cgroup #2855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

seongpil0948
Copy link

Which problem is this PR solving?

AWS ECS Fargate changed their cgroup naming convention to /ecs/<taskId>/<taskId>-<containerId> format. The existing container ID extraction logic only takes the last 64 characters, causing truncation in the middle of the taskId and resulting in incomplete container IDs like 438aa1824ca4058bdcab/c23e5f76c09d438aa1824ca4058bdcab-1234678 instead of the expected full c23e5f76c09d438aa1824ca4058bdcab-1234678.

This breaks compatibility with observability vendors like DataDog that require the complete taskId-containerId format for proper container identification.

Short description of the changes

  • Enhanced container ID extraction: Extract the last path segment from cgroup paths instead of truncating to 64 characters
  • New _extractContainerIdFromLine() method: Handles various container runtime formats (Docker, containerd, CRI-O) with proper prefix/suffix removal
  • Flexible validation: Uses permissive regex pattern [a-zA-Z0-9\-_]+ to support real-world container ID formats
  • Backward compatibility: Maintains fallback to original 64-char logic for legacy formats
  • Comprehensive tests: Added test cases covering DataDog compatibility scenarios and edge cases

Supported formats:

  • New ECS Fargate: /ecs/<taskId>/<taskId>-<containerId>taskId-containerId
  • Docker: /docker/containerid.scopecontainerid
  • Containerd: system.slice:cri-containerd:containeridcontainerid
  • UUID format: /uuid/34dc0b5e-626f-2c5c-4c51-70e34b10e76534dc0b5e-626f-2c5c-4c51-70e34b10e765

Fixes #2455

…paths

- Handle new AWS ECS cgroup format /ecs/<taskId>/<taskId>-<containerId>
- Prevent truncation by extracting last path segment instead of last 64 chars
- Support DataDog-compatible taskId-containerId format
- Maintain backward compatibility with legacy formats

Fixes open-telemetry#2455
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[detectors-aws] incomplete containerId detected for AWS ECS Fargate
2 participants